﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChMetody_3
{
    class Newton
    {
        public static double Solve(string[] args, double a, double b, double eps)
        {
            double x;
            double f = Functions.f(args[0], b);
            double f1, h;
            double f2 = Functions.f(args[2], b);
            if (f * f2 > 0)
            {
                x = b;
            }
            else 
            {
                x = a;
            }
            do {
                f = Functions.f(args[0], x);
                f1 = Functions.f(args[1], x);
                h = f / f1;
                x = x - h;
            } while (Math.Abs(h) >= eps);
            return x;
        }
    }
}

